﻿using System;
using System.Collections.Generic;

namespace JUtil.CodeGenerator
{
    public static class Util
    {
        private const char delimiter = ',';

        public static List<string> ToList(this string str)
        {
            string[] tokens = str.Split(new char[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);

            List<string> retVal = new List<string>();

            foreach (string token in tokens)
                retVal.Add(token.Trim());

            return retVal;
        }

        public static string Combinate(this List<string> lst)
        {
            string retVal = string.Empty;

            foreach (string token in lst)
            {
                if (!string.IsNullOrEmpty(retVal))
                    retVal += ", ";

                retVal += token;
            }

            return retVal;
        }
    }
}
